Set the current global draw info. All drawing is done based on the current draw info, so a group that is going to display must first call this method to make its draw info current.
*/
{
drawInfo = *info;
// Determine the nameMode (so this doesn't have to be done each time
// -fileStr is called)
switch ( drawInfo.mode ) {
case IC_LARGE_BROWSE:
nameMode = drawInfo.lb_nameMode; break;
case IC_SMALL_BROWSE:
nameMode = drawInfo.sb_nameMode; break;
case IC_LARGE_ICON:
case IC_SMALL_ICON:
default:
nameMode = IC_FILEONLY; break;
}
return ( self );
}
+ getDrawInfo:(DrawInfo *)info
{
*info = drawInfo;
return ( self );
}
+ (int)drawMode
{
return ( drawInfo.mode );
}
- calcCellSize:(NXSize *)size;
/*
Calculate the minimum size needed to draw the cell based in the current draw info.
*/
{
switch ( drawInfo.mode ) {
case IC_LARGE_BROWSE:
size->width = LB_WIDTH;
size->height = LB_HEIGHT;
break;
case IC_SMALL_BROWSE:
size->width = SB_WIDTH;
size->height = SB_HEIGHT;
break;
case IC_LARGE_ICON: // Shouldn't ever get called for this mode
case IC_SMALL_ICON: // Shouldn't ever get called for this mode
Draw only the interior of the cell. NOTE: For all Y coords used in drawing, it assumes that controlView will be flipped ( [controlView isFlipped] == YES ). This is because it assumes that it will always be drawn in a Matrix (or subclass), which is always flipped.
Called when a mouseDown: occurs within our frame. Currently does nothing. This might be used in the future to initiate direct editing of the path, appName, etc.
Reset the Item's fileStr to NULL so that it will be redetermined the next time it is drawn (actaully, the next time -fileStr gets called, which usually happens at draw time)
This method gets the item's file info from WM, which consists of its application, its type, and its extenstion.
*/
{
char *app;
id ws = [Application workspace];
NXAtom typ;
BOOL ok;
if ( !(path && strlen ( path )) )
return ( self );
fileType = FT_UNKNOWN;
ok = [ws getInfoForFile:path // Request file info from workspace
application:&app
type:&typ];
if ( ok ) { // WM got the info ok
// Copy the app name
if ( !specificApp ) {
if ( appName ) NX_FREE ( appName );
appName = NXCopyStringBuffer ( app );
}
// Determine the file type
if ( typ == NXDirectoryFileType || typ == NXFilesystemFileType )
fileType = FT_SUBDIR;
else
if ( typ == NXApplicationFileType || typ == NXShellCommandFileType )
fileType = FT_APPLICATION;
else
if ( typ == NXPlainFileType )
fileType = FT_FILE;
else
fileType = FT_FILE; // = FT_UNKNOWN;
}
return ( self );
}
- getIcon
/*
Get the icon for path. First it looks in the CustomIcons directory. Tiff images in this directory should be called [YY.<large|small>.tiff], where YY is the extension (e.g. 'h', 'm', 'snd'), and large means a normal (48x48) icon and small means a 1/4-size (24x24) icon. If it doesn't find a matching icon in the CustomIcons dir, it then tries to get it's icon from Workspace Manager.
*/
{
NXSize size;
NXImageRep *rep;
char *e, extension[50];
char iconPath[MAXPATHLEN+1], iconName[50];
id ws = [Application workspace];
NXImage *tempImage;
if ( !(path && strlen ( path )) )
return ( self );
/*
Get the item's normal-size icon image:
first look for it by extenstion in the ICONS_DIR, then get
Set the name of the app used to open the item. If this method is never called on an item, it uses the default app as determined by Workspace. If aString is NULL or an empty string, it goes back to using the default.
*/
{
NO_LONGER_STATIC;
if ( aString && strlen ( aString ) ) {
if ( !specificApp || strcmp ( appName, aString ) )
[group setChanged:YES];
// Set a specific app
specificApp = YES;
// Copy the app's name
appName = NXCopyStringBuffer ( aString );
} else {
if ( specificApp ) [group setChanged:YES];
// Use the default app
specificApp = NO;
}
[self getIcon];
[group setNeedsShow:YES];
return ( self );
}
- (const char *)appName
{
return ( appName );
}
- (BOOL)hasSpecificApp
/*
Returns NO if the Item will use the default application determined by Workspace, or YES if it will use a specific (user-specified) app
If flag is YES, then when this subdir is opened in Workspace, a new FileViewer will be created to display it. The new Viewer will be rooted at the path contained in rootAt.
*/
{
NO_LONGER_STATIC;
if ( createBrowser != flag ) {
createBrowser = flag;
[group setChanged:YES];
[group setNeedsShow:YES];
}
return ( self );
}
- rootBrowserAt:(const char *)fullPath
/*
Sets the path that will be the root directory for the FileViewer created in Workspace Manager when this item is opened. This only applies if createBrowser is true
A Dynamic Item isn't archived. It is a run-time only Item created from the Dynamic Item specs in the group. If a dynamic item is changed in any way (ie though the inspector, it has some properties set), then it is automatically set to be static, which means it then becomes a permanent part of the group.